<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">

<title>问诊中...</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="医疗问诊,智能问诊,问诊">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" href="./css/wx.css" />
<link rel="stylesheet" href="./css/weui.css" />
<link rel="stylesheet" href="./css/example.css" />
<link rel="stylesheet" href="./js/bootstrap-3.3.5-dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="./js/bootstrap-multiselect/bootstrap-multiselect.css" type="text/css"/>
<link rel="stylesheet" href="./js/font-awesome/css/font-awesome.min.css">

<script type="text/javascript" src="./js/jquery.min.js"></script>
<script type="text/javascript" src="./js/jquery.js"></script>
<script type="text/javascript" src="./js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="./js/bootstrap-3.3.5-dist/js/bootstrap.js"></script>
<script src="./js/bootstrap-table/bootstrap-table-all.min.js"></script>
<script src="./js/bootstrap-table/bootstrap-table-zh-CN.min.js"></script>
<script src="./js/bootstrap-jquery-plugin/jquery.bootstrap.js"></script>
<script src="./js/bootstrap-multiselect/bootstrap-multiselect.js"></script>
<script src="./js/bootstrap-3.3.5-dist/js/bootstrap-datetimepicker.js"></script>
<script src="./js/bootstrap-3.3.5-dist/js/bootstrap.min.js"></script>
<script type="text/javascript" src="./js/wx.js"></script>
<script type="text/javascript" src="./js/zepto.min.js"></script>
<script type="text/javascript" src="./js/example.js"></script>

<style type="text/css">
#section{
	margin-bottom: 100px;
}
.doctor{
	clear: both; 
}
.doctor-span{
	list-style:none; /* 将默认的列表符号去掉 */
	padding:8px; /* 将默认的内边距去掉 */
	margin-top:6px; /* 将默认的外边距去掉 */
	border-radius:7px;
	height: auto;
	background-color: rgba(73, 86, 187, 0.32);
}

.arrow-left{
	width: 0;
    height: 0;
    line-height: 0;
    font-size: 0;
    border-color: transparent rgba(73, 86, 187, 0.32) transparent transparent;
    border-width: 6px;
    border-style: dashed solid dashed dashed;
    top: 8px;
    left: -12px;
    z-index: 999;
}

.arrow-right{
	width: 0;
    height: 0;
    line-height: 0;
    font-size: 0;
    border-color: transparent transparent transparent rgba(20, 247, 5, 0.35);
    border-width: 6px;
    border-style: dashed solid dashed dashed;
    top: 8px;
    left: -12px;
    z-index: 999;
    float:right;
    margin-top: 19px;
}

option{
	text-align:center;
}

.select-bor{
	text-align: center;
	width:80%;
	border:1px solid rgba(60, 118, 61, 0.26);
	border-radius: 5px;
	margin : 3px 0;
}

.doctor	ul li{
	list-style:none; /* 将默认的列表符号去掉 */
	padding:8px; /* 将默认的内边距去掉 */
	margin-top:6px; /* 将默认的外边距去掉 */
	border-radius:8px;
	height: auto;
	display : inline;
	background-color: #efefef;
	text-align: center;
	display : -webkit-inline-box;
}
.asker{
	margin-left: 62px;
	width: 55%;
	position : relative;
}
.asker ul li {
	list-style:none; /* 将默认的列表符号去掉 */
	padding:8px; /* 将默认的内边距去掉 */
	margin-top:6px; /* 将默认的外边距去掉 */
	float:left; /* 往左浮动 */
	border-radius:8px;
	height: auto;
	background-color: #efefef;
}

.asker ul li span{
	vertical-align:-webkit-baseline-middle;
}
.answer-1-div {
	position: relative;
}
.answer-1{
	list-style:none; /* 将默认的列表符号去掉 */
	padding:8px; /* 将默认的内边距去掉 */
	margin-top:4px 8px 0 0; /* 将默认的外边距去掉 */
	float:right; /* 往左浮动 */
	border-radius:7px;
	height: auto;
	background-color: rgba(20, 247, 5, 0.35);
	margin: 0 10px 0 65px;
}
.asker{
	width: 100%
}
.img-radius{
	width:40px;
	height:40px;
	border-radius: 50%;
	margin:8px;
}
.weui_extra_area ul li{
	list-style:none; /* 将默认的列表符号去掉 */
	padding:8px; /* 将默认的内边距去掉 */
	float:left; /* 往左浮动 */
	height: auto;
}
.weui_extra_area ul.showsyms li {
	list-style:none; /* 将默认的列表符号去掉 */
	float:left; /* 往左浮动 */
	height: auto;
	background-color: rgba(0, 0, 0, 0);
}
.isSelect {
	background-color:#efefef;
	background-image: url(./images/click.png) !important;
	background-repeat: no-repeat;
    background-position: right bottom !important;
	color: #23598A;
	border-radius:5px;
}
#table tr{
	border-bottom: 1px solid #fff;
}
footer{
	position:fixed ;
	bottom: 0;
	width: 100%
}
footer ul{
	margin-bottom :0
}
footer ul li {
	height: 40px;
	background-color: #efefef;
	color: #fff
}
footer ul li p{
	position:absolute;
	margin-top: -11px;
	margin-left: 42%
}
#selector-1{
	background-color: #337ab7;
}

#selector-2{
	background-color: #337ab7;
}

.img_border{
	border: 1px solid red;
}
</style>
<script type="text/javascript">
var storage = window.localStorage;
//初始化数据
storage.setItem("medicines","");
storage.setItem("illName","");
storage.setItem("askMedicines","");
storage.setItem("assistantExam","");
storage.setItem("symptomsArr","");
storage.setItem("scheme","");
storage.setItem("suggest","");
storage.setItem("tabooMedicine","");
storage.setItem("pastHistorys","");

var part = getUrlParam("part");
var symptom = getUrlParam("symptom");
var urlids = getUrlParam("ids");
var degree = getUrlParam("degree");
var nature = getUrlParam("nature");
var times = getUrlParam("times");
var tp = getUrlParam("tp");
var url = getUrlParam("url");
var factor = getUrlParam("factor");

var symptomsArr = getUrlParam("symptomsArr");
var urlUsedSymptoms = getUrlParam("usedSymptoms");
var urlUsedParts = getUrlParam("usedParts");

//使用过的病症
var usedSymptoms = [];
var usedSymptomsObj = [];
var urlObj = {
	symptom : symptom,
	degree : degree,
	nature : nature,
	times :　times,
	urls : url,
	value : tp,
	factor : factor
}
usedSymptomsObj.push(urlObj);
//使用过的部位
var usedParts = [];
//所有剩下的部位
var allParts = [];
//当前ids
var currentIds = [];
//未使用过的病症
var currentPartSymptoms = [];
//未使用过的部位
var currentParts = [];
//当前的数据源
var currentData = [];
//当前选择的病症
var currentSelectSymptoms = [];

//ds
var externalSymptoms = [];
var isDS = true;

var illName = '';

var sex = storage.getItem("sex");

function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return  decodeURI(r[2]); return null;
}

//当前选择的症状
var currentSymptoms = [];

$(document).ready(function() {
	$("#selector-2").hide();
	usedSymptoms.push(symptom);
	usedParts.push(part);
	if(symptom && symptom!=''){
		$.ajax({
	        url: "./newIllOper/getIllByIdAndsymptomsAndPart.spring",
	        data: {
	        	ids : urlids,
	        	part : part,
	        	isImportant : 0,
	        	symptom : symptom,
	        	degree :　degree,
	        	nature : nature,
	        	times : times,
	        	factor : factor,
	        	tp : tp,
	        	symptoms : usedSymptoms.join(","),
	        	parts : usedParts.join(",")
	        },
	        type: "POST",
	        dataType: 'json',
	        cache: false,
	        success: function (ret) {
	        	currentIds = ret.content;//赋值全局ids
	        	if(currentIds.length==0){
	        		alert("您查询的疾病不存在，请联系您主治医生，给您带来不便请谅解！");
	        		window.location.href="./jsp/conditionsList.jsp";
	        	}else{
	        		//获取这些ids的信息
	        		getIllByIds();
	        	}
	        }
        });
	}else{
		$.ajax({
	        url: "./newIllOper/getIllByIdAndPart.spring",
	        data: {
	        	ids : urlids,
	        	part : part,
	        	symptoms : usedSymptoms.join(","),
	        	parts : usedParts.join(",")
	        },
	        type: "POST",
	        dataType: 'json',
	        cache: false,
	        success: function (ret) {
	        	currentIds = ret.ids;
	        	currentPartSymptoms = ret.symptoms;
	        	currentParts = ret.parts;
	        	
	        	if(currentIds.length==0){
	        		alert("您查询的疾病不存在，请联系您主治医生，给您带来不便请谅解！");
	        		window.location.href="./jsp/conditionsList.jsp";
	        	}else{
	        		showSymptomsByDoc(currentPartSymptoms);
	        	}
	        }
        });
	}
});

var pastHistoryArr = [];
var incentiveArr = [];
var medicineHistoryArr = [];
function getIllByIds(){
	$.ajax({
        url: "./newIllOper/getIllByIds",
        data: {
        	ids : currentIds.join(",")
        },
        type: "POST",
        dataType: 'json',
        cache: false,
        success: function (ret) {
        	for(var i=0;i<ret.length;i++){
        		currentData.push(ret[i]);
        	}
        	allParts = getAllParts();
        	
			for(var i=0;i<currentData.length;i++){
				var arr = currentData[i].symptoms;
				for(var j=0;j<arr.length;j++){
					var pastHistory = arr[j].pastHistory;
					var incentive = arr[j].incentive;
					var medicineHistory = arr[j].medicineHistory;
					if(pastHistory!='' && pastHistory!=null){
						pastHistoryArr.push(pastHistory);
					}
					if(incentive!='' && incentive!=null){
						incentiveArr.push(incentive);
					}
					if(medicineHistory!='' && medicineHistory!=null){
						medicineHistoryArr.push(medicineHistory);
					}
				}
			}
			pastHistoryArr = unique(pastHistoryArr);
			incentiveArr = unique(incentiveArr);
			medicineHistoryArr = unique(medicineHistoryArr);
			if(pastHistoryArr.length>0){
				mod = 1;
				showSymptomsByDoc(pastHistoryArr);
			}else if(pastHistoryArr.length == 0 && incentiveArr.length>0 ){
				mod = 2;
				showSymptomsByDoc(incentiveArr);
			}else if(pastHistoryArr.length == 0 && incentiveArr.length==0 && medicineHistoryArr.length>0){
				mod = 3;
				showSymptomsByDoc(medicineHistoryArr);				
			}else{
				var part_arr = selectSymptomByPart(part);
				if(part_arr.length>0){
					showSymptomsByDoc(part_arr);
				}else{
					showSymptomsByDoc(getNoNullPartSymps());
				}
			}
        }
    });
}

//获取疾病的所有部位
function getAllParts(){
	var partArr = [];
	for(var i=0;i<currentData.length;i++){
		var arr = currentData[i].symptoms;
		for(var j=0;j<arr.length;j++){
			var part = arr[j].parts;
			if(!isInArray(usedParts,part)){
				partArr.push(part);
			}
		}
	}
	return unique(partArr);
}

//根据部位筛选出病症
function selectSymptomByPart(part){
	var partSymptoms = [];
	for(var i=0;i<currentData.length;i++){
		var arr = currentData[i].symptoms;
		for(var j=0;j<arr.length;j++){
			var symptom = arr[j].symptom;
			if(arr[j].parts==part && !isInArray(usedSymptoms,symptom)){
				if(arr[j].pastHistory!='' && arr[j].pastHistory!=null && !isInArray(currentSelectPastHistorys,arr[j].pastHistory)){
					continue;
				}
				if(arr[j].incentive!='' && arr[j].incentive!=null && isInArray(currentSelectIncentives,arr[j].incentive)){
					continue;
				}
				if(arr[j].medicineHistory!='' && arr[j].medicineHistory!=null && isInArray(currentSelectMedicineHistorys,arr[j].medicineHistory)){
					continue;
				}
				if(isInArray(pastHistoryArr,symptom) || isInArray(incentiveArr,symptom) || isInArray(medicineHistoryArr,symptom)){
					if(isInArray(currentSelectPastHistorys,symptom) || isInArray(currentSelectIncentives,symptom) || isInArray(currentSelectMedicineHistorys,symptom)){
						var obj_1 = {
							symptom : symptom,
							degree : '',
							nature : '',
							times :　'',
							urls : '',
							value : '',
							factor : ''
						}
						usedSymptomsObj.push(obj_1);
					}
					continue;
				}
				if(arr[j].sex!=null && arr[j].sex!=2){
					if(arr[j].sex=sex){
						partSymptoms.push(symptom);
					}
					continue;
				}
				partSymptoms.push(symptom);
			}
		}
	}
	partSymptoms = unique(partSymptoms);//去重
	usedSymptoms = usedSymptoms.concat(partSymptoms);//插入已选病症 
	return partSymptoms;
}

//判断元素是否在数组里面
function isInArray(arr,value){
    for(var i = 0; i < arr.length; i++){
        if(value === arr[i]){
            return true;
        }
    }
    return false;
}

//数组去重
function unique(arr) {
    var result = [], isRepeated;
    for (var i = 0;i<arr.length;i++) {
        isRepeated = false;
        for (var j = 0;j<result.length;j++) {
            if (arr[i] == result[j]) {   
                isRepeated = true;
                break;
            }
        }
        if (!isRepeated) {
            result.push(arr[i]);
        }
    }
    return result;
}

var doctor = 1;
var mod = 0;//当前模式
function showSymptomsByDoc(data){
	var section = document.getElementById("section");
	var div = document.createElement("div");
	div.id = "doctor"+doctor;
	div.className = "doctor";
	var lis = '';
	var modText = "请问您是否具有以下情况？"
	if(mod==1){
		modText = "请问您是否具有以下既往史？";
	}else if(mod==2){
		modText = "请问您是否具有以下诱因？";
	}else if(mod==3){
		modText = "请问您是否具有以下药物服用史？";
	}else if(mod==5){
		modText = "您最可能患有以下几种疾病：";
	}else if(mod==6){
		modText = "病情分析：";
	}
	if(mod==6){
		lis += data
	}else{
		for(var i=0;i<data.length;i++){
			lis += '<li style="margin:3px;" id="'+data[i]+'" onclick="selectSyms(\''+data[i]+'\')">'+data[i]+'</li>';
		}
	}

	if(mod!=5){
		lis += '<li style="margin:3px;" id="以上都无'+doctor+'" onclick="selectSyms(\'以上都无'+doctor+'\')">以上都无</li>';
	}

	if(mod==6){

		div.innerHTML = '<div style="width:100%;"><img alt="" src="./images/logo.jpg" class="img-radius" >'
				+'<span class="arrow-left">&nbsp;</span><span class="doctor-span">'
				+ modText
				+'</span></div>'
				+'<div style="margin-left:65px;">'
				+ data.replace(/\n/g, '<br>')
				+'</div>';

	}else{
		div.innerHTML = '<div style="width:100%;"><img alt="" src="./images/logo.jpg" class="img-radius" >'
				+'<span class="arrow-left">&nbsp;</span><span class="doctor-span">'
				+ modText
				+'</span></div>'
				+'<div style="margin-left:65px;"><ul>'
				+lis
				+'</ul></div>';
	}
	section.appendChild(div);
	doctor++;
}

function showSymptomsByAnswer(data){
	var section = document.getElementById("section");
	var div = document.createElement("div");
	div.className = "answer-1-div";
	div.innerHTML = '<li style="list-style-type: none;">'
					+'<span class="answer-1">'
							+data
						+'</span></li>';
	section.appendChild(div);
}

//获取二级病症列表
function getSecSymptomInData(symptom){
	var degrees = [];
	var natures = [];
	var timess = [];
	var urls = [];
	var tp = [];
	var factors = [];
	for(var i=0;i<currentData.length;i++){
		var arr = currentData[i].symptoms;
		for(var j=0;j<arr.length;j++){
			if(arr[j].symptom==symptom){
				if(arr[j].degree!=null && arr[j].degree!=''){
					degrees.push(arr[j].degree);
				}
				if(arr[j].nature!=null && arr[j].nature!=''){
					natures.push(arr[j].nature);
				}
				if(arr[j].times!=null && arr[j].times!=''){
					timess.push(arr[j].times);
				}
				if(arr[j].imgurl!=null && arr[j].imgurl!=''){
					urls.push(arr[j].imgurl);
				}
				if(arr[j].sdown!=null && arr[j].sdown!='' ){
					tp.push(arr[j].sdown);
				}
				if(arr[j].factor!=null && arr[j].factor!='' ){
					factors.push(arr[j].factor);
				}				
				if(arr[j].sup!=null && arr[j].sup!=''){
					tp.push(arr[j].sup);
				}
			}
		}
	}
    var tpMax = tp.max();
    var tpMin = tp.min();
    var tps = [];
       	if(tpMin!=tpMax){
       		if(symptom=="体温" || symptom=="发烧" || symptom=="低体温"){
       			for(var x=tpMin;x<tpMax;){
       				var xx = Number(x).toFixed(1);
       				tps.push(xx);
	       			x = x+0.1;
	       		}
       		}else{
       			for(var x=tpMin;x<tpMax;x++){
       				var xx = Number(x).toFixed(0);
       				tps.push(xx);
	       		}
       		}
      	}	    
	var obj = {
		degrees : unique(degrees),
		natures : unique(natures),
		timess :　unique(timess),
		urls　: unique(urls),
		tps : unique(tps),
		factors : unique(factors)
	}
	return obj;
}

	Array.prototype.min = function() {
		var min = this[0];
		var len = this.length;
		for (var i = 1; i < len; i++){ 
			if (this[i] < min){ 
				min = this[i]; 
			} 
		} 
		return min;
	}
	//最大值
	Array.prototype.max = function() { 
		var max = this[0];
		var len = this.length; 
		for (var i = 1; i < len; i++){ 
			if (this[i] > max) { 
				max = this[i]; 
			} 
		} 
		return max;
	}

var curr_img_select_arr = [];
//展示二级病症
function showSecSymptom(data){
	curr_img_select_arr = [];
	if(!data.indexOf("以上都无")){
		var obj = {
			symptom : data,
			degree : '',
			nature : '',
			times : '',
			urls : '',
			value : '',
			factor : ''
		}
		currentSelectSymptoms.push(obj);
		return ;
	}
	var ret = getSecSymptomInData(data);
	if(ret.degrees.length==0 && ret.natures.length==0 && ret.timess.length==0 && ret.urls.length==0 && ret.tps.length==0 && ret.factors.length==0){
		var obj = {
			symptom : data,
			degree : '',
			nature : '',
			times : '',
			urls : '',
			value : '',
			factor : ''
		}
		currentSelectSymptoms.push(obj);
		return ;
	}
	$("#symptomBox").show();
	$("#symptomName").text(data);
	
    var table = document.getElementById("table");
	var tr = document.createElement("div");
	tr.id = 'table-'+data;
	var html = '';
	var degrees_sel = '<option value="">无</option>';
	for(var i=0;i<ret.degrees.length;i++){
		 degrees_sel += '<option value="'+ret.degrees[i]+'">'+ret.degrees[i]+'</option>'
	}
	if(ret.degrees.length>0){
		html += '<div>程度：<select class="weui_select select-bor" id="select-degree">'+degrees_sel+'</select></div>';
	}
	
	var natures_sel = '<option value="">无</option>';
	for(var i=0;i<ret.natures.length;i++){
		 natures_sel += '<option value="'+ret.natures[i]+'">'+ret.natures[i]+'</option>'
	}
	if(ret.natures.length>0){
		html += '<div >性质：<select class="weui_select select-bor" id="select-nature" style="text-align: center;">'+natures_sel+'</select></div>';
	}
	
	var timess_sel = '<option value="">无</option>';
	for(var i=0;i<ret.timess.length;i++){
		 timess_sel += '<option value="'+ret.timess[i]+'">'+ret.timess[i]+'</option>'
	}
	if(ret.timess.length>0){
		html += '<div >周期：<select class="weui_select select-bor" id="select-times" style="text-align: center;">'+timess_sel+'</select></div>';
	}
	
	var factors_sel = '<option value="">无</option>';
	for(var i=0;i<ret.factors.length;i++){
		 factors_sel += '<option value="'+ret.factors[i]+'">'+ret.factors[i]+'</option>'
	}
	if(ret.factors.length>0){
		html += '<div >因素：<select class="weui_select select-bor" id="select-factor" style="text-align: center;">'+factors_sel+'</select></div>';
	}
	
	if(ret.urls.length>0){
		for(var i=0;i<ret.urls.length;i++){
			 curr_img_select_arr.push(ret.urls[i]);
		}
		html += '<div>图片：<input type="text" id="select-url" onclick="showPic()" class="weui_select select-bor" placeholder="请选择图片"/></div>';
	}
	
	var tps_sel = '<option value="">无</option>';
	for(var i=0;i<ret.tps.length;i++){
		 tps_sel += '<option value="'+ret.tps[i]+'">'+ret.tps[i]+'</option>'
	}
	if(ret.tps.length>0){
		html += '<div>数值：<select class="weui_select select-bor" id="select-tp" style="text-align: center;">'+tps_sel+'</select></div>';
	}
	
	tr.innerHTML = html;
    table.appendChild(tr);
}

var currentSelectPastHistorys = [];
var currentSelectIncentives = [];
var currentSelectMedicineHistorys = [];
storage.setItem("pastHistorys", currentSelectPastHistorys.join(","));
//var selectIll = '';
function selectSyms(data){
	if(mod==5){
		return;
	}else{
		if($("#"+data).hasClass("isSelect")){
			$("#"+data).removeClass("isSelect");
			if(mod==1){
				for(var i=0;i<currentSelectPastHistorys.length;i++){
					if(currentSelectPastHistorys[i]==data){
						currentSelectPastHistorys.splice(i,1);
					}
				}
			}else if(mod==2){
				for(var i=0;i<currentSelectIncentives.length;i++){
					if(currentSelectIncentives[i]==data){
						currentSelectIncentives.splice(i,1);
					}
				}
			}else if(mod==3){
				for(var i=0;i<currentSelectMedicineHistorys.length;i++){
					if(currentSelectMedicineHistorys[i]==data){
						currentSelectMedicineHistorys.splice(i,1);
					}
				}
			}else{
				for(var i=0;i<usedSymptomsObj.length;i++){
					if(usedSymptomsObj[i].symptom==data){
						usedSymptomsObj.splice(i,1);
					}
				}
				for(var i=0;i<currentSelectSymptoms.length;i++){
					if(currentSelectSymptoms[i].symptom==data){
						currentSelectSymptoms.splice(i,1);
					}
				}
			}
		}else{
			if(mod==1){
				if(!data.indexOf("以上都无")){
					for(var xx=0;xx<currentSelectPastHistorys.length;xx++){
						$("#"+currentSelectPastHistorys[xx]).removeClass("isSelect");
					}
					currentSelectPastHistorys = [];
				}else{
					var s = "以上都无"+(doctor-1);
					for(var xx=0;xx<currentSelectPastHistorys.length;xx++){
						if(currentSelectPastHistorys[xx]==s){
							currentSelectPastHistorys.splice(xx,1);
						}
					}
					$("#"+s).removeClass("isSelect");
				}
				currentSelectPastHistorys.push(data);
			}else if(mod==2){
				currentSelectIncentives.push(data);
				if(!data.indexOf("以上都无")){
					for(var xx=0;xx<currentSelectIncentives.length;xx++){
						$("#"+currentSelectIncentives[xx]).removeClass("isSelect");
					}
					currentSelectIncentives = [];				
				}else{
					var s = "以上都无"+(doctor-1);
					for(var xx=0;xx<currentSelectIncentives.length;xx++){
						if(currentSelectIncentives[xx]==s){
							currentSelectIncentives.splice(xx,1);
						}
					}					
					$("#"+s).removeClass("isSelect");
				}
			}else if(mod==3){
				currentSelectMedicineHistorys.push(data);
				if(!data.indexOf("以上都无")){
					for(var xx=0;xx<currentSelectMedicineHistorys.length;xx++){
						$("#"+currentSelectMedicineHistorys[xx]).removeClass("isSelect");
					}
					currentSelectMedicineHistorys = [];				
				}else{
					var s = "以上都无"+(doctor-1);
					for(var xx=0;xx<currentSelectMedicineHistorys.length;xx++){
						if(currentSelectMedicineHistorys[xx]==s){
							currentSelectMedicineHistorys.splice(xx,1);
						}
					}
					$("#"+s).removeClass("isSelect");
				}				
			}else{
				if(!data.indexOf("以上都无")){
					for(var xx=0;xx<currentSelectSymptoms.length;xx++){
						$("#"+currentSelectSymptoms[xx].symptom).removeClass("isSelect");
					}
					currentSelectSymptoms = [];				
				}else{
					var s = "以上都无"+(doctor-1);
					for(var xx=0;xx<currentSelectSymptoms.length;xx++){
						if(currentSelectSymptoms[xx].symptom==s){
							currentSelectSymptoms.splice(xx,1);
						}
					}
					$("#"+s).removeClass("isSelect");
				}			
				showSecSymptom(data);
			}
			$("#"+data).addClass("isSelect");
		}
	}
}

//当前选择的病症
var symdata = [];
var sendOverFlag = false;
var warning = 0;
var symMedicines = [];


//点击确认
function send(){
	var selectSymptomArr = [];
	$(".doctor").find('li').each(function(){
		$(this).removeAttr("onclick");
	});
	if(mod==1){
		for(var i1=0;i1<currentSelectPastHistorys.length;i1++){
			if(!currentSelectPastHistorys[i1].indexOf("以上都无")){
				currentSelectPastHistorys = [];
				break;
			}
		}
		//设置选择的既往史
		storage.setItem("pastHistorys", currentSelectPastHistorys.join(","));
		showSymptomsByAnswer(currentSelectPastHistorys.join("、")==''?"以上都无" : currentSelectPastHistorys.join("、"));
		mod++;
		if(incentiveArr.length>0 ){
			showSymptomsByDoc(incentiveArr);
		}else if(incentiveArr.length==0 && medicineHistoryArr.length>0){
			mod++;
			showSymptomsByDoc(medicineHistoryArr);				
		}else{
			mod++;
			mod++;
			if(part!=null && part!=''){
				var part_arr = selectSymptomByPart(part);
				if(part_arr.length>0){
					showSymptomsByDoc(part_arr);
				}else{
					showSymptomsByDoc(getNoNullPartSymps());
				}
			}else{
				showSymptomsByDoc(getNoNullPartSymps());
			}
		}
	}else if(mod==2){
		for(var i1=0;i1<currentSelectIncentives.length;i1++){
			if(!currentSelectIncentives[i1].indexOf("以上都无")){
				currentSelectIncentives = [];
				break;
			}
		}
		showSymptomsByAnswer(currentSelectIncentives.join("、")==''?"以上都无":currentSelectIncentives.join("、"));
		mod++;
		if(medicineHistoryArr.length>0){
			showSymptomsByDoc(medicineHistoryArr);
		}else{
			mod++;
			if(part!=null && part!=''){
				var part_arr = selectSymptomByPart(part);
				if(part_arr.length>0){
					showSymptomsByDoc(part_arr);
				}else{
					showSymptomsByDoc(getNoNullPartSymps());
				}
			}else{
				showSymptomsByDoc(getNoNullPartSymps());
			}
		}
	}else if(mod==3){
		for(var i1=0;i1<currentSelectMedicineHistorys.length;i1++){
			if(!currentSelectMedicineHistorys[i1].indexOf("以上都无")){
				currentSelectMedicineHistorys = [];
				break;
			}
		}
		showSymptomsByAnswer(currentSelectMedicineHistorys.join("、")==''?"以上都无":currentSelectMedicineHistorys.join("、"));
		mod++;
		if(part!=null && part!=''){
			var part_arr = selectSymptomByPart(part);
			if(part_arr.length>0){
				showSymptomsByDoc(part_arr);
			}else{
				showSymptomsByDoc(getNoNullPartSymps());
			}
		}else{
			showSymptomsByDoc(getNoNullPartSymps());
		}
	}else if(mod==5){
		
	}else{

		//处理每一次问答
		var mess = ""
		if(currentSelectSymptoms.length>0){
			for(x=0;x<currentSelectSymptoms.length;x++){

				mess += ("有症状："+currentSelectSymptoms[x].symptom);

				if(currentSelectSymptoms[x].degree){
					mess += ('，程度为'+currentSelectSymptoms[x].degree)
				}
				if(currentSelectSymptoms[x].nature){
					mess += ('，性质为'+currentSelectSymptoms[x].nature)
				}
				if(currentSelectSymptoms[x].times){
					mess += ('，周期为'+currentSelectSymptoms[x].times)
				}
				if(currentSelectSymptoms[x].value){
					mess += ('，数值为'+currentSelectSymptoms[x].value)
				}
				if(currentSelectSymptoms[x].factor){
					mess += ('，因素为'+currentSelectSymptoms[x].factor)
				}

				mess += ';';

			}
		}

		if(mess){
			currentSymptoms.push({
				'content':mess,
				'role':'user'
			})
		}


		var sym = getUsedSymptomsObjOfSymptom();
		if(sym==''){
			showSymptomsByAnswer("以上都无");
		}else{
			showSymptomsByAnswer(sym);
		}
		var noNullPartSymps_arr = getNoNullPartSymps();
		if(noNullPartSymps_arr.length>0){
			sendOverFlag = false;
			showSymptomsByDoc(noNullPartSymps_arr);
		}else{
			sendOverFlag = true;
		}


	}

	if(sendOverFlag){
		var illArr = illNessSortByIsImportant();
		mod = 5;
		var length = illArr.length;
		var dataArr = [];
		var dataArr1 = [];

		var messList = [];

		messList.push({
			"content":"你是一个丰富的全科医生",
			"role":"system"
		})


		//重新组织deepseek答案
		//{"content":"现在有一个30岁的患者","role":"user"}
		if(currentSymptoms.length>0){
			messList = messList.concat(currentSymptoms)
		}

		if(isDS){

			var $loadingToast = $('#loadingToast');
			if ($loadingToast.css('display') != 'none') {
				return;
			}
			$loadingToast.show();

			//组装DS
			var dsdata = {
					"frequency_penalty":"0",
					"logprobs":false,
					"max_tokens":"2049",
					"messages":messList,
					"model":"deepseek-chat",
					"presence_penalty":0,
					"response_format":{
						"type":"text"
					},
					"stream":false,
					"temperature":1,
					"tool_choice":"none",
					"top_p":1
					};
			//return;
			var url= "./deepseek/askDs";
			$.ajax({
				url : url,
				data : JSON.stringify(dsdata),
				type : "POST",
				dataType: 'json',
				contentType:"application/json",
				success : function(data) {

					$loadingToast.hide();

					//console.log(data.choices.message.content);
					mod = 6;
					showSymptomsByDoc(data.choices[0].message.content);

					$("#btn-text").html("完成");
					setTimeout(function(){},1000)
					$("#selector-1").removeAttr("onclick");
					$("#selector-1").hide();
					$("#selector-2").show();
					scrollWindow();
				}
			});

		}else{
			if(length==0){
				alert("您未患有任何疾病");
				window.location.href="./jsp/conditionsList.jsp";
			}else if(length==1){
				dataArr.push("1、"+illArr[0].ill);
				dataArr1.push(illArr[0].ill);
				illName = illArr[0].ill;
			}else if(length==2){
				dataArr.push("1、"+illArr[0].ill);
				dataArr.push("2、"+illArr[1].ill);
				dataArr1.push(illArr[0].ill);
				dataArr1.push(illArr[1].ill);
				illName = illArr[1].ill;
			}else{
				dataArr.push("1、"+illArr[illArr.length-1].ill);
				dataArr.push("2、"+illArr[illArr.length-2].ill);
				dataArr.push("3、"+illArr[illArr.length-3].ill);
				dataArr1.push(illArr[illArr.length-1].ill);
				dataArr1.push(illArr[illArr.length-2].ill);
				dataArr1.push(illArr[illArr.length-3].ill);
				illName = illArr[illArr.length-1].ill;
			}
			showSymptomsByDoc(dataArr);
			storage.setItem("illName", dataArr1.join(","));
			$("#btn-text").html("完成");
			setTimeout(function(){},1000)
			$("#selector-1").removeAttr("onclick");
			$("#selector-1").hide();
			$("#selector-2").show();
			scrollWindow();
		}
	}
	scrollWindow();
}

function end(){
	var scheme;
			var medicine;
			var description = '';
	
			for(var i=0;i<currentData.length;i++){
				if(currentData[i].illness==illName){
					scheme = currentData[i].scheme;
					medicine = currentData[i].medicine;
					warning = currentData[i].warning;
					var symss = currentData[i].symptoms;
					for(var j=0;j<symss.length;j++){
						for(var y=0;y<usedSymptomsObj.length;y++){
							if(usedSymptomsObj[y].symptom==symss[j].symptom){
								if(usedSymptomsObj[y].degree==(symss[j].degree==null?'':symss[j].degree)){
								if(usedSymptomsObj[y].factor==(symss[j].factor==null?'':symss[j].factor)){
								if(usedSymptomsObj[y].nature==(symss[j].nature==null?'':symss[j].nature)){
								if(usedSymptomsObj[y].times==(symss[j].times==null?'':symss[j].times)){
								if(usedSymptomsObj[y].value>=(symss[j].sdown==null?0:symss[j].sdown) && usedSymptomsObj[y].value<=(symss[j].sup==null?0:symss[j].sup)){
									if(symss[j].medicine!=null && symss[j].medicine!=''){
										symMedicines.push(symss[j].medicine);//需判断
									}
								}	
								}
								}	
								}
								}	

								if(symss[j].warning>warning || symss[j].warning==4){
									warning = symss[j].warning;
									if(symss[j].description!=null && symss[j].description!=''){
										description = symss[j].description;
									}
								}
							}
						}
					}
				}
			}
	
			spliceSymptom();
			
			storage.setItem("assistantExam", '');
			storage.setItem("symptomsArr", symptomsArr);
			storage.setItem("scheme", scheme);
			storage.setItem("askMedicines", "");
			
			if(warning==1){
				$("#warningBox").show();
				var h = "<span style=\"color:green\"><span class=\"glyphicon glyphicon-info-sign\" aria-hidden=\"true\"></span></span>"
					  + "根据我们系统的诊断结果<br>判断您目前的病情基本平稳<br>建议您根据我们给出的治疗方案从家庭药箱取药或自行购药治疗<br>并在家中休息观察<br>如病情加重请及时到医院就诊";
				$("#warningBoxText").html(h);
				storage.setItem("askMedicines", medicine);
				storage.setItem("suggest", "根据我们系统的诊断结果，判断您目前的病情基本平稳，建议您根据我们给出的治疗方案从家庭药箱取药或自行购药治疗 ，并在家中休息观察，如病情加重请及时到医院就诊。");
			}else if(warning==2){
				$("#warningBox").show();
				var h = "<span style=\"color:blue\"><span class=\"glyphicon glyphicon-info-sign\" aria-hidden=\"true\"></span></span>"
					  + "根据我们系统的诊断结果<br>判断您目前的病情需要到医疗机构进一步就医治疗<br>我们建议你尽快安排时间<br>前往医疗机构进一步检查治疗";
				$("#warningBoxText").html(h);
				storage.setItem("askMedicines", "");
				storage.setItem("suggest", "根据我们系统的诊断结果，判断您目前的病情需要到医疗机构进一步就医治疗，我们建议你尽快安排时间，前往医疗机构进一步检查治疗。");
			}else if(warning==3){
				$("#warningBox").show();
				var h = "<span style=\"color:yellow\"><span class=\"glyphicon glyphicon-info-sign\" aria-hidden=\"true\"></span></span>"
					  + "根据我们系统的诊断结果<br>您的病情比较危急<br>需要立即到医疗机构就诊以免耽误病情";
				$("#warningBoxText").html(h);
				storage.setItem("askMedicines", "");
				storage.setItem("suggest", "根据我们系统的诊断结果，您的病情比较危急，需要立即到医疗机构就诊以免耽误病情。");
			}else if(warning==4){
				$("#warningBox").show();
				var h = "<span style=\"color:red\"><span class=\"glyphicon glyphicon-info-sign\" aria-hidden=\"true\"></span></span>"
					  + "根据我们系统的诊断结果<br>你目前的病情比较危重<br>不宜活动<br>建议你立即拨打当地的急救电话或者120等待救援";
				$("#warningBoxText").html(h);
				storage.setItem("askMedicines", "");
				storage.setItem("suggest", "根据我们系统的诊断结果，你目前的病情比较危重，不宜活动，建议你立即拨打当地的急救电话或者120等待救援。");
			}else{
				OK();
			}
		
}

function getNoNullPartSymps(){
	var arr = [];
	if(allParts.length>0){
		var apart;
		for(var i=0;i<=allParts.length;i++){
			var p = allParts[0];
			arr = selectSymptomByPart(p);
			allParts.shift();
			if(allParts.length>0){
				if(arr.length>0){
					return arr;
				}
			}else{
				return arr;
			}
			i=0;
		}
	}else{
		return arr;
	}
}

var jumpUrl;

function OK(){
	disclaimerBox();
	return;
}

function spliceSymptom(){
	for(var j=0;j<usedSymptomsObj.length;j++){
		if(usedSymptomsObj[j].symptom==null || usedSymptomsObj[j].symptom==""){
			return "";
		}
		symptomsArr += usedSymptomsObj[j].symptom+"，";
		if(usedSymptomsObj[j].degree && usedSymptomsObj[j].degree!=""){
			symptomsArr += usedSymptomsObj[j].degree+"，";
		}
		if(usedSymptomsObj[j].nature && usedSymptomsObj[j].nature!=""){
			symptomsArr += usedSymptomsObj[j].nature+"，";
		}
		if(usedSymptomsObj[j].factor && usedSymptomsObj[j].factor!=""){
			symptomsArr += usedSymptomsObj[j].factor+"，";
		}
		if(usedSymptomsObj[j].times && usedSymptomsObj[j].times!=""){
			symptomsArr += usedSymptomsObj[j].times+"，";
		}
		if(usedSymptomsObj[j].value && usedSymptomsObj[j].value!=""){
			symptomsArr += usedSymptomsObj[j].value+"，";
		}
		symptomsArr = symptomsArr.substring(0,symptomsArr.length-1)+'。';
	}
}

//遍历疾病中存在多少症状
function illNessSortByIsImportant(){
	//疾病排序
	var illOBJ = [];
	for(var i=0;i<currentData.length;i++){
		//当前疾病
		var ill = currentData[i];
		//当前疾病症状列表
		var symptoms_1 = ill.symptoms;
		//当前选择的症状列表
		var usedSymptomsObj_1 = usedSymptomsObj;
		//当前疾病症状总数
		var sum = symptoms_1.length;

		//当前疾病限制症状数
		var limitNum = 0;
		
		//当前疾病重要症状数
		var importantNum = 0;
		//重要症状总数
		var importantSum = 0;
		
		//当前疾病普通症状数
		var commonNum = 0;
		//普通症状总数
		var commomSum = 0;
		
		//普通症状百分比
		var commonPercentage = 0;
		//重要症状百分比
		var importantPercentage = 0;
		//记录有多少个已选择病症符合这个疾病的
		var usedSymptomsObj_1_num = 0; 
		for(var j=0;j<symptoms_1.length;j++){
			if(symptoms_1[j].isImportant==0){
				importantSum++;
			}else{
				commomSum++;
			}
			
			for(var x=0;x<usedSymptomsObj_1.length;x++){
				if(symptoms_1[j].symptom==usedSymptomsObj_1[x].symptom){
					
					if((symptoms_1[j].degree==null?'':symptoms_1[j].degree)==usedSymptomsObj_1[x].degree
						&& (symptoms_1[j].nature==null?'':symptoms_1[j].nature)==usedSymptomsObj_1[x].nature
						&& (symptoms_1[j].times==null?'':symptoms_1[j].times)==usedSymptomsObj_1[x].times
						&& (symptoms_1[j].urls==null?'':symptoms_1[j].urls)==usedSymptomsObj_1[x].urls
						&& (symptoms_1[j].factor==null?'':symptoms_1[j].factor)==usedSymptomsObj_1[x].factor){
						if(usedSymptomsObj_1[x].value>=(symptoms_1[j].sdown==null?0:symptoms_1[j].sdown)
							&& usedSymptomsObj_1[x].value<=(symptoms_1[j].sup==null?0:symptoms_1[j].sup)){
							usedSymptomsObj_1_num++;
							if(symptoms_1[j].isImportant==0){
								//记录该疾病有多少重要症状
								importantNum++;
								//计算该疾病有多少限制症状
								if(symptoms_1[j].limitSymptoms==0){
									limitNum++;
								}
							}else{
								//记录疾病有多少普通症状
								commonNum++;
							}
						}
					}
				}
			}
		}
		
		if(usedSymptomsObj_1.length>usedSymptomsObj_1_num){//若一个或以上症状不对应的，直接跳过
			continue;
		}

		var obj;
		if(ill.limitNum>=limitNum){
			obj = {
				ill : ill.illness,
				importantNum : importantNum,
				commonNum : commonNum,
				importantPercentage : (importantSum==0?0:(importantNum/importantSum)),
				commonPercentage : (commomSum==0?0:(commonNum/commomSum))
			};
		}else{
			obj = {
				ill : ill.illness,
				importantNum : -1,
				commonNum : commonNum,
				importantPercentage : 0,
				commonPercentage : 0
			};
		}

		if(illOBJ.length==0){
			illOBJ.push(obj);
		}else{
		 	for(var y=0;y<illOBJ.length;y++){
		 		if(illOBJ[y].importantNum>importantNum){
		 			illOBJ.splice(y,0,obj);
					break;
		 		}else if(illOBJ[y].importantNum==importantNum){
		 			if(illOBJ[y].importantPercentage>importantPercentage){
		 				illOBJ.splice(y,0,obj);
						break;
		 			}else if(illOBJ[y].importantPercentage==importantPercentage){
		 				if(illOBJ[y].commonNum>commonNum){
		 					illOBJ.splice(y,0,obj);
							break;
		 				}else if(illOBJ[y].commonNum==commonNum){
		 					if(illOBJ[y].commonPercentage>commonPercentage){
		 						illOBJ.splice(y,0,obj);
								break;
		 					}else{
		 						illOBJ.splice(y+1,0,obj);
								break;
		 					}
		 				}else{
		 					illOBJ.splice(y+1,0,obj);
							break;
		 				}
		 			}else{
		 				illOBJ.splice(y+1,0,obj);
						break;
		 			}
		 		}else{
		 			illOBJ.splice(y+1,0,obj);
					break;
		 		}
		 	}
/* 			for(var y=0;y<illOBJ.length;y++){
				if(illOBJ[y].num>num){
					illOBJ.splice(y,0,obj);
					break;
				}else if(illOBJ[y].num==num){
					if(illOBJ[y].commonNum>usedCommonNum){
						illOBJ.splice(y,0,obj);
						break;
					}else{
						illOBJ.splice(y+1,0,obj);
						break;
					}
				}else{
					illOBJ.splice(y+1,0,obj);
					break;
				}
				if(y==illOBJ.length){
					illOBJ.splice(y+1,0,obj);
					break;
				}
			} */
		}
	}
	return illOBJ;
}


/* function illNessSortByIsImportant(){
	//疾病排序
	var illOBJ = [];
	for(var i=0;i<currentData.length;i++){
		var num = 0;
		var limitNum = 0;
		var ill = currentData[i];
		var percentage = 0;
		var currIllIsImportantNum = 0;
		var usedCommonNum = 0;
		var symptoms_1 = ill.symptoms;
		for(var j=0;j<symptoms_1.length;j++){
			if(symptoms_1[j].isImportant==0){
				currIllIsImportantNum++;
			}
			for(var x=0;x<usedSymptomsObj.length;x++){
				if(symptoms_1[j].symptom==usedSymptomsObj[x].symptom){
					if(symptoms_1[j].degree==usedSymptomsObj[x].degree && symptoms_1[j].nature==usedSymptomsObj[x].nature 
						&& symptoms_1[j].times==usedSymptomsObj[x].times && symptoms_1[j].urls==usedSymptomsObj[x].urls
						&& symptoms_1[j].factor==usedSymptomsObj[x].factor){
						if(usedSymptomsObj[x].value>symptoms_1[j].sdown && usedSymptomsObj[x].value<symptoms_1[j].sup){
							if(symptoms_1[j].isImportant==0){
								//记录该疾病有多少重要症状
								num++;
								//计算该疾病有多少限制症状
								if(symptoms_1[j].limitSymptoms==0){
									limitNum++;
								}
							}else{
								//记录疾病有多少普通症状
								usedCommonNum++;
							}
						}
					}
				}
			}
		}

		var obj;
		if(ill.limitNum>=limitNum){
			obj = {
				ill : ill.illness,
				num : num,
				commonNum:usedCommonNum
			};
		}else{
			obj = {
				ill : ill.illness,
				num : -1,
				commonNum:usedCommonNum
			};
		}

		if(illOBJ.length==0){
			illOBJ.push(obj);
		}else{
			for(var y=0;y<illOBJ.length;y++){
				if(illOBJ[y].num>num){
					illOBJ.splice(y,0,obj);
					break;
				}else if(illOBJ[y].num==num){
					if(illOBJ[y].commonNum>usedCommonNum){
						illOBJ.splice(y,0,obj);
						break;
					}else{
						illOBJ.splice(y+1,0,obj);
						break;
					}
				}else{
					illOBJ.splice(y+1,0,obj);
					break;
				}
				if(y==illOBJ.length){
					illOBJ.splice(y+1,0,obj);
					break;
				}
			}
		}
	}
	return illOBJ;
} */

//获取勾选了的病症
function getUsedSymptomsObjOfSymptom(){
   	var str = '';
	for(var i=0;i<currentSelectSymptoms.length;i++){
		if(!currentSelectSymptoms[i].symptom.indexOf("以上都无")){
			currentSelectSymptoms = [];
			str = '、';
			break;
		}else{
			str += currentSelectSymptoms[i].symptom+"<br>";
		}
	}
	usedSymptomsObj = usedSymptomsObj.concat(currentSelectSymptoms);//插入已选病症 
	currentSelectSymptoms = [];
	return str.substring(0,str.length-1);
}

function showSyms() {
	var divheigth = document.getElementById("syms").offsetHeight;
	var realheigth = divheigth - 45;
	if ($("#showorhide").text() == "∨") {
		$("#syms").stop().animate({
			bottom : -realheigth + "px"
		}, 400);
		$("#selector").stop().animate({
			bottom : -realheigth + "px"
		}, 400);
		$("#showorhide").text("∧");
	} else {
		$("#syms").stop().animate({
			bottom : "0px"
		}, 400);
		$("#selector").stop().animate({
			bottom : "0px"
		}, 400);
		$("#showorhide").text("∨");
	}
}

function cancle(){
	var obj = {
		symptom : $("#symptomName").text(),
		degree : '',
		nature : '',
		times : '',
		urls : '',
		value : '',
		factor : ''
	}
	currentSelectSymptoms.push(obj);
	$("#table").html('');
	$("#symptomBox").hide();
}

function comimt(){
	//程度
	var degree = $("#select-degree").find("option:selected").val()?$("#select-degree").find("option:selected").val():'';
	//性质
	var nature = $("#select-nature").find("option:selected").val()?$("#select-nature").find("option:selected").val():'';
	//周期
	var times = $("#select-times").find("option:selected").val()?$("#select-times").find("option:selected").val():'';
	//因素
	var factor = $("#select-factor").find("option:selected").val()?$("#select-factor").find("option:selected").val():'';
	var url = $("#select-url").text()=="undefined"?'':$("#select-url").text();
	//数值
	var value = $("#select-tp").find("option:selected").val()?$("#select-tp").find("option:selected").val():0;
	var obj = {
		symptom : $("#symptomName").text(),
		degree : degree,
		nature : nature,
		times : times,
		urls : url,
		value : value,
		factor : factor
	}

	currentSelectSymptoms.push(obj);

	$("#table").html('');
	$("#symptomBox").hide();
}

//设置滚动条到最底部
function scrollWindow(){ 
    scroll(0, 100000); 
}

function closeThis(){
	$("#warningBox").hide();
	$("#warning").html('');
}

function showPic(){
	$("#picBox").show();
    
    var im = document.getElementById("im");
    var ims = document.createElement("div");
    var html_img ='';
    for(var i=0;i<curr_img_select_arr.length;i++){
    	html_img+= '<img alt="" src="../img/'+curr_img_select_arr[i]+'" style="width:100%;margin:2px 0px" onclick="select_this_img(\''+curr_img_select_arr[i]+'\',this)"></br>';
    }
   	ims.innerHTML = html_img;
   	im.appendChild(ims);
     
}

function IMG_OK(){
	$("#picBox").hide();
	$("#im").html('');
	$("#select-url").val(select_this_imgs[0]?select_this_imgs[0]:"无");
}

var select_this_imgs = [];
function select_this_img(t,tt){
	console.log(t);
	$("#im").find("img").removeClass("img_border");
	$(tt).addClass("img_border");
	select_this_imgs = [];
	select_this_imgs.push(t);
}

function disclaimerBox(){
	$("#warningBox").hide();
	$("#disclaimerBox").show();
}

function Disclaimer_OK(){
	if(warning==1){//wring=1的取疾病的药物
		window.location.href = "./jsp/medicineAsking.jsp";
	}else{//大于1的取病症的药物
		if(symMedicines.length>0){
			var syarr = '';
			//同样的病症归类
			for(var i=0;i<symMedicines.length;i++){
				syarr = syarr + symMedicines[i] + "、"; 
			}
			storage.setItem("askMedicines", syarr.substring(0,syarr.length-1));
			
			window.location.href = "./jsp/medicineAsking.jsp";
		}else{
			window.location.href = "./jsp/talkResult.jsp";
		}
	}
	return;
}

function Disclaimer_ON(){
	window.location.href="./jsp/conditionsList.jsp";
}
</script>
</head>
<body >
	<%--<div>
		<select id="ds">
			<option>norm</option>
			<option>AI</option>
		</select>
	</div>--%>
	<section>
		<div id="section">
	</section>	
	<%--<div class="weui_dialog_confirm" id="symptomBox" style="display: none;">
	    <div class="weui_mask"></div>
	    <div class="weui_dialog">
	        <div class="weui_dialog_hd"><strong class="weui_dialog_title">请选择‘<span id="symptomName"></span>’的描述</strong></div>
	        <div class="weui_dialog_bd" id="table"></div>
	        <div class="weui_dialog_ft">
	            <a href="javascript:;" class="weui_btn_dialog primary" onclick="comimt()">确定</a>
	            <a href="javascript:;" class="weui_btn_dialog default" style="color: #ff0000 !important;" onclick="cancle()">取消</a>
	        </div>
	    </div>
	</div>--%>
	<div class="weui_dialog_confirm" id="warningBox" style="display: none;">
	    <div class="weui_mask"></div>
	    <div class="weui_dialog" style="border-radius: 10px !important;">
	    	<div style="position: relative;">
	    		<img alt="" src="./images/logo.jpg" style="width: 55px;height: 55px;border-radius: 50%;margin: 5px;" >
	    		<!-- <img alt="" src="" style="width: 100%;"> -->
	    		<p id="warningBoxText" style="padding: 5px 5px 0px 5px;"></p>
	    		<span class="del fa fa-times" aria-hidden="true" onclick="OK()" style="position: absolute; top: 2px;right: 2px;font-size: 24px;"></span>
	    	</div>
	    </div>
	</div>
	<%--<div class="weui_dialog_confirm" id="picBox" style="display: none;">
	    <div class="weui_mask"></div>
	    <div class="weui_dialog" >
	    	<div style="margin:15px 0;border-bottom: 1px solid #efefef;padding-bottom:8px;">症状图片</div>
	    	<div id="im" style="height:300px; overflow:auto;"></div>
	        <div class="weui_dialog_ft">
	            <a href="javascript:;" class="weui_btn_dialog primary" onclick="IMG_OK()">确定</a>
	        </div>
	    </div>
	</div>--%>
	<div id="loadingToast" class="weui_loading_toast" style="display: none;">
		<div class="weui_mask_transparent"></div>
		<div class="weui_toast">
			<div class="weui_loading">
				<div class="weui_loading_leaf weui_loading_leaf_0"></div>
				<div class="weui_loading_leaf weui_loading_leaf_1"></div>
				<div class="weui_loading_leaf weui_loading_leaf_2"></div>
				<div class="weui_loading_leaf weui_loading_leaf_3"></div>
				<div class="weui_loading_leaf weui_loading_leaf_4"></div>
				<div class="weui_loading_leaf weui_loading_leaf_5"></div>
				<div class="weui_loading_leaf weui_loading_leaf_6"></div>
				<div class="weui_loading_leaf weui_loading_leaf_7"></div>
				<div class="weui_loading_leaf weui_loading_leaf_8"></div>
				<div class="weui_loading_leaf weui_loading_leaf_9"></div>
				<div class="weui_loading_leaf weui_loading_leaf_10"></div>
				<div class="weui_loading_leaf weui_loading_leaf_11"></div>
			</div>
			<p class="weui_toast_content">正在分析...</p>
		</div>
	</div>
	<div class="weui_dialog_confirm" id="disclaimerBox" style="display: none;">
	    <div class="weui_mask"></div>
	    <div class="weui_dialog" >
	    	<div style="margin:15px 0;border-bottom: 1px solid #efefef;padding-bottom:8px;font-size: 20px;">郑重承诺</div>
	    	<p style="color: #000;font-size: 13px;">我已经阅读并遵守<a>《<!-- 蒙估大夫 -->免责声明》</a></p>
	        <div class="weui_dialog_ft">
	            <a href="javascript:;" class="weui_btn_dialog primary" onclick="Disclaimer_OK()">确定</a>
	            <a href="javascript:;" class="weui_btn_dialog primary" style="color: #ff0000 !important;" onclick="Disclaimer_ON()">取消</a>
	        </div>
	    </div>
	</div>
	<div style="height: 1px">
	</div>
	<footer>
		<ul>
			<li onclick="send();" id="selector-1"><p id="btn-text" style="margin-top: 8px !important;">发送</p></li>
			<li onclick="end();" id="selector-2"><p id="btn-text" style="margin-top: 8px !important;">完成</p></li>
		</ul>
	</footer>
</body>
</html>
